<template>
    <view>
        <!-- mine/pages/refundRecord/refundRecord.wxml -->
        <view class="reRecBox" v-if="recordList.length > 0">
            <view class="record_item" @tap="goRefundDetails" :data-id="item.id" v-for="(item, index) in recordList" :key="index">
                <view class="itemDisplay1">
                    <image src="https://oos-cn.ctyunapi.cn/front-end/static/mine/images/refund_wx.png" class="img1"></image>
                    <view class="itemRight">
                        <view class="itemDisplay">
                            <view class="itemTitle">
                                <view class="name">{{ item.refundRoad == 'WeChatPay' ? '原路退回微信' : item.refundRoad == 'Alipay' ? '原路退回支付宝' : item.refundRoad }}</view>
                            </view>
                            <view class="changeAmount">
                                {{ item.balance / 100 }}
                                <image src="https://oos-cn.ctyunapi.cn/front-end/static/mine/images/turn.png" class="img"></image>
                            </view>
                        </view>
                        <view class="itemDisplay">
                            <view class="time">{{ item.createTime ? item.createTime : '暂无' }}</view>
                            <view class="type1" v-if="item.checkStatus == 'Approve'">退款成功</view>
                            <view class="type2" v-if="item.checkStatus == 'AwaitingApproval' || item.checkStatus == 'AwaitingReApproval'">审核中</view>
                            <view class="type2" v-if="item.checkStatus == 'DisApprove'">退款失败</view>
                            <view class="type2" v-if="item.checkStatus == 'HangIn'">挂起中</view>
                            <!-- <view class="type1">退款成功</view>
          <view class="type2">审核中</view>
          <view class="type3">退款失败</view> -->
                        </view>
                    </view>
                </view>
            </view>
            <view class="noList" v-if="LoadingComplete">全部加载完成</view>
        </view>
        <view v-else>
            <Upgrading text="暂无退款记录"></Upgrading>
        </view>
    </view>
</template>

<script>
	'use strict';
	import Upgrading from '../../../components/upgrading/upgrading';

	// exports.__esModule = true; // mine/pages/refundRecord/refundRecord.ts

	var https_1 = require('./../../../api/https.js');
	export default {
		components: {
			Upgrading
		},
		data() {
			return {
				page: 1,
				pages: 1,
				pageSize: 10,
				LoadingComplete: false,
				recordList: []
			};
		},
		/**
		 * 生命周期函数--监听页面加载
		 */
		onLoad: function () {},
		/**
		 * 生命周期函数--监听页面初次渲染完成
		 */
		onReady: function () {},
		/**
		 * 生命周期函数--监听页面显示
		 */
		onShow: function () {
			this.getRefundRecordList('replace');
		},
		/**
		 * 页面相关事件处理函数--监听用户下拉动作
		 */
		onPullDownRefresh: function () {
			//调用刷新时将执行的方法
			this.page = 1
			this.pages = 1
			this.recordList = []
			this.getRefundRecordList('replace');
		},
		//  * 页面上拉触底事件的处理函数
		onReachBottom: function () {
			var that = this;
			var page = that.page + 1;

			if (that.page < that.pages) {
				that.page = page
				this.getRefundRecordList('');
			}
		},
		/**
		 * 生命周期函数--监听页面隐藏
		 */
		onHide: function () {
			this.page = 1
		},
		/**
		 * 生命周期函数--监听页面卸载
		 */
		onUnload: function () {},
		/**
		 * 用户点击右上角分享
		 */
		onShareAppMessage: function () {},
		methods: {
			//退款或不可退列表
			getRefundRecordList: function (type) {
				var that = this;
				uni.showLoading({
					title: '加载中...',
					mask: true
				});
				https_1
					.refundRecordList({
						page: this.page,
						pageSize: this.pageSize
					})
					.then(function (res) {
						if (res.code == 0) {
							that.page = res.data.current
							that.pages = res.data.pages
							if (res.data.current == res.data.pages) {
								that.setData({
									LoadingComplete: true
								});
							}

							var list = res.data.records || [];
							uni.hideLoading();

							if (list.length == 0 && res.data.current == 1) {
								that.setData({
									recordList: []
								});
								return false;
							}

							if (type === 'replace') {
								that.setData({
									recordList: list
								});
							} else {
								that.setData({
									recordList: that.recordList.concat(list)
								});
							}
						}
					})
					['catch'](function () {
					uni.hideLoading();
				});
			},

			//退款详情
			goRefundDetails: function (e) {
				var id = e.currentTarget.dataset.id;
				uni.navigateTo({
					url: '../refundDetails/refundDetails?refundId=' + id
				});
			}
		}
	};
</script>
<style lang="less">
    @import url('./refundRecord.less');
    /* mine/pages/refundRecord/refundRecord.wxss */
</style>
